package 力扣日常刷题.木22二月.第17天223;

import 力扣日常刷题.ListNode;

import java.util.List;

/**
 * @author 帅小伙
 * @date 2022/2/23
 * @description
 */
public class Demo151环形链表 {


    public boolean hasCycle(ListNode head) {
        if (head == null || head.next == null) return false;
        ListNode fast = head.next;
        ListNode slow = head;
        while (fast != slow) {
            if (slow == null || fast == null || fast.next == null) {
                return false;
            }
            slow = slow.next;
            fast = fast.next.next;
        }
        return true;
    }
}
